

***open raw data from the Survey of professional forecasters.

clear
import excel "micro5.xlsx", sheet("PRUNEMP") firstrow

foreach var in PRUNEMP1 PRUNEMP2 PRUNEMP3 PRUNEMP4 PRUNEMP5 PRUNEMP6 PRUNEMP7 PRUNEMP8 PRUNEMP9 PRUNEMP10 ///
PRUNEMP11 PRUNEMP12 PRUNEMP13 PRUNEMP14 PRUNEMP15 PRUNEMP16 PRUNEMP17 PRUNEMP18 PRUNEMP19 PRUNEMP20 ///
PRUNEMP21 PRUNEMP22 PRUNEMP23 PRUNEMP24 PRUNEMP25 PRUNEMP26 PRUNEMP27 PRUNEMP28 PRUNEMP29 PRUNEMP30 ///
PRUNEMP31 PRUNEMP32 PRUNEMP33 PRUNEMP34 PRUNEMP35 PRUNEMP36 PRUNEMP37 PRUNEMP38 PRUNEMP39 PRUNEMP40{
destring `var', replace force
}

keep if QUARTER==2
keep if YEAR>=2013 & YEAR<=2016


gen unemp_current=.
replace unemp_current=7.5 if YEAR==2013
replace unemp_current=6.3 if YEAR==2014
replace unemp_current=5.5 if YEAR==2015
replace unemp_current=4.7 if YEAR==2016

* Now need to calculate probability mass assigned to outcomes greater than the current rate.

/* Coding of variables:

See p.46 of document "spf-documentation.pdf".

Need to use PRUNEMP11-PRUNEMP20
2013: Probability mass assigned to unemployment rate at least equal to 7.5 corrsponds to sum over PRUNEMP11 until PRUNEMP17.
2014: Probability mass assigned to unemployment rate at least equal to 6.3 corrsponds to sum over PRUNEMP11 until PRUNEMP15.
2015: Probability mass assigned to unemployment rate at least equal to 5.5 corrsponds to sum over PRUNEMP11 until PRUNEMP17.
2016: Probability mass assigned to unemployment rate at least equal to 4.7 corrsponds to sum over PRUNEMP11 until PRUNEMP18.

*/

gen prob_unemp_incr=.
replace prob_unemp_incr=PRUNEMP11+PRUNEMP12+PRUNEMP13+PRUNEMP14+PRUNEMP15+PRUNEMP16+PRUNEMP17 if YEAR==2013
replace prob_unemp_incr=PRUNEMP11+PRUNEMP12+PRUNEMP13+PRUNEMP14+PRUNEMP15 if YEAR==2014
replace prob_unemp_incr=PRUNEMP11+PRUNEMP12+PRUNEMP13+PRUNEMP14+PRUNEMP15+PRUNEMP16+PRUNEMP17 if YEAR==2015
replace prob_unemp_incr=PRUNEMP11+PRUNEMP12+PRUNEMP13+PRUNEMP14+PRUNEMP15+PRUNEMP16+PRUNEMP17+PRUNEMP18 if YEAR==2016

/*
Now produce plots separately for each year and merge each of them with a corresponding plot from the SCE.
May even put them on top of each other. Could leave that to Chris.
Later on can use "xcommon" and "ycommon" in order to adjust scales.
*/

saveold "SPF_probunemp_clean.dta", v(13) replace


use "SPF_probunemp_clean.dta", clear


cd "$path_figures"

forvalues i=2013/2016{
hist prob_unemp_incr if YEAR==`i', width(4) ytitle("Fraction") xtitle("Percent chance higher" "unemployment (professional forecasters)")
graph save "prob_unemp_incr_SPF_`i'.gph", replace
}


cd "$path_SCE"
use "SCE_clean.dta", clear

cd "$path_figures"

forvalues i=2013/2016{
hist perc_unemphigher_ny if year==`i' & month==6, width(4) ytitle("Fraction") xtitle("Percent chance higher" "unemployment (consumers)")
graph save "prob_unemp_incr_SCE_`i'.gph", replace
}

forvalues i=2013/2016{
graph combine prob_unemp_incr_SPF_`i'.gph prob_unemp_incr_SCE_`i'.gph, xcommon ycommon
graph save "prob_unemp_incr_comp_`i'.gph", replace
graph export "prob_unemp_incr_comp_`i'.pdf", replace
}

graph combine prob_unemp_incr_comp_2013.gph prob_unemp_incr_comp_2014.gph, cols(1)
graph export "prob_unemp_incr_comp_2013_2014.pdf", replace

graph combine prob_unemp_incr_comp_2015.gph prob_unemp_incr_comp_2016.gph, cols(1)
graph export "prob_unemp_incr_comp_2015_2016.pdf", replace

graph combine prob_unemp_incr_comp_2013.gph prob_unemp_incr_comp_2014.gph ///
prob_unemp_incr_comp_2015.gph prob_unemp_incr_comp_2016.gph, cols(1)
graph export "prob_unemp_incr_comp_all.pdf", replace


















